package com.boomsecret.pattern.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangjinliang on 2018/1/24.
 */
public class Platform implements Subject {
    private List<Observer> observers = null;

    public Platform() {
        this.observers = new ArrayList<>();
    }

    @Override
    public void attach(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void detach(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyMsg() {
        observers.forEach(observer -> {
            observer.update("push msg.");
        });
    }
}
